Create AI Model
Used to create a new AI model with specified configuration. This allows you to integrate various AI models from different providers into your project.
API Endpoint
| Property | Value |
|---|---|
| Request Method | POST |
| Request URL | https://api.seliseblocks.com/models/ |
Request
Request Example
curl -X POST 'https://api.seliseblocks.com/models/' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"provider": "openai",
"service_platform": "official_api",
"version": "gpt-4",
"model_name": "gpt-4-turbo-preview",
"project_key": "YOUR_PROJECT_KEY",
"display_name": "GPT-4 Turbo",
"api_key": "sk-your-api-key-here",
"base_url": "https://api.openai.com/v1",
"MaxTokens": 8192,
"DefaultTemp": 0.7
}'
Request Headers
| Field | Type | Required | Description |
|---|---|---|---|
| accept | string | Yes | Accepted response format. Use application/json |
| Content-Type | application/json | Yes | Data type, must be application/json. |
Request Body
Request Body Schema
{
"provider": "openai",
"service_platform": "official_api",
"version": "string",
"model_name": "string",
"project_key": "string",
"display_name": "string",
"api_key": "string",
"base_url": "string",
"openai_organization_id": "string",
"openai_project_id": "string",
"api_version": "string",
"deployment_name": "string",
"custom_parameters": {
"additionalProp1": {}
},
"custom_headers": {
"additionalProp1": {}
},
"MaxTokens": 8192,
"DefaultTemp": 0.7
}
Request Body Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| provider | string | Yes | AI model provider (e.g., "openai", "anthropic", "azure", "google"). |
| service_platform | string | Yes | Service platform type (e.g., "official_api", "azure", "custom"). |
| version | string | Yes | Model version identifier. |
| model_name | string | Yes | Specific model name (e.g., "gpt-4-turbo-preview", "claude-3-opus"). |
| project_key | string | Yes | The project key for your project. |
| display_name | string | Yes | Human-readable display name for the model. |
| api_key | string | Yes | API key for authentication with the provider. |
| base_url | string | No | Base URL for API requests (defaults to provider's standard URL). |
| openai_organization_id | string | No | OpenAI organization ID (for OpenAI models only). |
| openai_project_id | string | No | OpenAI project ID (for OpenAI models only). |
| api_version | string | No | API version (required for Azure OpenAI). |
| deployment_name | string | No | Deployment name (required for Azure OpenAI). |
| custom_parameters | object | No | Additional custom parameters for the model. |
| custom_headers | object | No | Custom HTTP headers for API requests. |
| MaxTokens | integer | No | Maximum number of tokens the model can generate (default: 8192). |
| DefaultTemp | number | No | Default temperature for generation (default: 0.7, range: 0-2). |
note
Provider-Specific Requirements
- OpenAI: Requires
api_key, optionallyopenai_organization_idandopenai_project_id - Azure OpenAI: Requires
api_key,base_url,api_version, anddeployment_name - Anthropic: Requires
api_key, model name like "claude-3-opus-20240229" - Google: Requires appropriate authentication credentials in
api_key - Custom providers: May require
base_urlandcustom_headers
tip
Best practices for model configuration:
- Use descriptive display names to easily identify models
- Store API keys securely and rotate them regularly
- Set appropriate MaxTokens based on your use case and budget
- Start with DefaultTemp of 0.7 and adjust based on output quality
- Test model configuration after creation
- Document model-specific parameters in custom_parameters
- Use separate models for development and production
Temperature guidelines:
- 0.0-0.3: More deterministic, factual responses
- 0.4-0.7: Balanced creativity and consistency (recommended default)
- 0.8-1.0: More creative and varied responses
- 1.1-2.0: Highly creative, potentially less coherent
The system will:
- Validate API credentials during creation
- Test connectivity to the model provider
- Store credentials securely (encrypted at rest)
- Make the model available for AI agents immediately
- Track model usage and costs
Response
Success Response (201 Created)
Returns an object containing the creation status.
{
"is_success": true,
"item_id": "model_123",
"detail": "AI model created successfully",
"error": {}
}
Response Fields
| Field | Type | Description |
|---|---|---|
| is_success | boolean | Indicates whether the creation was successful. |
| item_id | string | The unique identifier of the created model. |
| detail | string | Success or failure message with additional context. |
| error | object | Error details if the operation failed (empty if successful). |
Error Response (422 Unprocessable Entity)
Returns validation error details when the request body is invalid.
{
"detail": [
{
"loc": [
"body",
"api_key"
],
"msg": "Invalid API key format or authentication failed",
"type": "value_error.authentication"
}
]
}
Error Response Fields
| Field | Type | Description |
|---|---|---|
| detail | array | Array of validation error objects. |
| loc | array | Location of the error in the request (e.g., body field). |
| msg | string | Human-readable error message. |
| type | string | Error type identifier. |
Common Error Scenarios
| Error Type | Description | Resolution |
|---|---|---|
| Invalid API Key | API key is incorrect or expired | Verify API key from provider dashboard |
| Authentication Failed | Provider rejected credentials | Check API key permissions and quotas |
| Invalid Model Name | Model name doesn't exist or is misspelled | Verify model name with provider documentation |
| Missing Required Field | Required provider-specific field missing | Add required fields (e.g., deployment_name for Azure) |
| Connection Failed | Cannot connect to provider's API | Check base_url and network connectivity |
| Quota Exceeded | Provider API quota exceeded | Upgrade plan or wait for quota reset |
Error Codes
| Status Code | Description | Response Type |
|---|---|---|
| 201 | Created - Model created successfully | Success |
| 400 | Bad Request - Invalid model configuration | Bad Request |
| 401 | Unauthorized - Invalid API credentials | Unauthorized |
| 409 | Conflict - Model with same name already exists | Conflict |
| 422 | Validation Error - Invalid request parameters | Unprocessable Entity |
| 503 | Service Unavailable - Provider API unavailable | Service Unavailable |